using System;
using System.Collections.Generic;
using Microsoft.Practices.ServiceLocation;
using StructureMap;

namespace Roommate.Infrastructure.IoC
{
    public class StructureMapServiceLocator : ServiceLocatorImplBase
    {
        protected override object DoGetInstance(Type serviceType, string key)
        {
            return string.IsNullOrEmpty(key)? ObjectFactory.GetInstance(serviceType) : ObjectFactory.GetNamedInstance(serviceType, key);
        } 
        protected override IEnumerable<object> DoGetAllInstances(Type serviceType) { return GetAllInstances(serviceType); }
    }
}